<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //Math.random() 取随机值，0~1，包含0不包含1的小数
    //如果变换随机值的范围，可以乘以对应的值(0~8的随机值，可以乘以9再取整)
    var result =  Math.random();
    console.log(result);

    var arr = ["hello","world","javascript","math"];
    var index = result*arr.length;
    index = parseInt(index); 
    console.log(arr[index]);

</script>
</html>